const jwt = require('jsonwebtoken')

const key = 'liang-ge'

const JWT = {
  generator(data, time) {
    try {
      return jwt.sign(data, key, { expiresIn: time })
    } catch (error) {
      console.log(err)
    }
  },
  verify(token) {
    try {
      return jwt.verify(token, key)
    } catch (error) {
      console.log(error)
      return null
    }
  },
}

module.exports = JWT
